from rest_framework.serializers import Serializer
from rest_framework import serializers

from demo.models import Stu,Tea



# 关联学生表
class TeaRealated(serializers.ModelSerializer):
    class Meta:
        model = Tea
        fields = '__all__'

# 多表
class StuSerializer(serializers.ModelSerializer):
    sid = TeaRealated(read_only=True)
    class Meta:
        model = Stu
        fields = '__all__'






# 关联老师的表
class StuRealated(serializers.ModelSerializer):
    class Meta:
        model = Stu
        fields = '__all__'
# 一表
class TeaSerializer(serializers.ModelSerializer):
    stu = StuRealated(read_only=True, many=True)
    class Meta:
        model = Tea
        fields = '__all__'
